1. /* sdmpsrnd.cpp by K.Tsuru */
  2. // function ID = 343 DRADIX, BRADIX
  3. /********************************************************************************
  4. SDouble and SDecimal class
  5. It provides the Boolean value whether it is possible to round off or not.
  6. Counting from the last position of effective figures, if it conatins "n9or0" over
  7. (radix-1)'s or zeros, it returns 'true' else 'false'.
  8. 0.1233 9999 9999 9999 ..... 9999 9875 4578 or
  9. 0.1234 0000 0000 0000 ..... 0000 0000 0001
  10. is rounded off,it becomes 0.1234.
  11. Perhaps it may set "n9or0" as two or three figures.
  12. **********************************************************************************/
  13. #ifndef SN_H
  14. #include "sn.h"
  15. #endif
  16. bool SDouble::IsPossibleToRound(uint n9or0) const {
  17. uint ef = EffFig();
  18. if(!n9or0 || (n9or0 > ef) || (aHead < ef) ) return false;
  19. if(!Sign(343)) return true;
  20. fType rdx_1 = Radix() -1;
  21. uint j = 0;
  22. bool cr = false;
  23. if(figure(ef) == rdx_1){
  24. while( (figure(ef--) == rdx_1) && (j < n9or0) ) j++;
  25. if(j == n9or0) cr = true;
  26. } else if(figure(ef) == 0){
  27. while( (figure(ef--) == 0) && (j < n9or0) ) j++;
  28. if(j == n9or0) cr = true;
  29. }
  30. return cr;
  31. }

sdmpsrnd.cpp : last modifiled at 2017/03/13 14:31:57(1,169 bytes)
created at 2017/10/07 10:21:15
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).